package jwr.ex;

import java.util.InputMismatchException;
import java.util.Scanner;

public class ProductInfo {
	
	public static int stid=1; 
	
	public static void main(String[] args) {
		Scanner sc = null;
		int sw[] = new int[2];
		
		int cnt = 0;
		Product[] pd;
		pd = new Product[100];
		do{
			sc = new Scanner(System.in);
			try{
				System.out.print("상품 추가<1>, 모든 상품 조회<2>, 끝내기<3> >>");
				sw[0] = sc.nextInt();
				switch (sw[0]){
					case 1 :
						System.out.print("상품 종류 책<1>, 음악CD<2>, 회화책<3> >>");
						sw[1] = sc.nextInt();
						
						switch (sw[1]) {
							case 1:
								pd[cnt] = new Product(1);
								System.out.print("상품 설명>>");
								pd[cnt].setMenu(sc.next());
								System.out.print("생산자>>");
								pd[cnt].setCon(sc.next());
								System.out.print("가격>>");
								pd[cnt].setPrice(sc.nextInt());
								System.out.print("책제목>>");
								pd[cnt].setBookTitle(sc.next());
								System.out.print("저자>>");
								pd[cnt].setAuthor(sc.next());
								break;
							case 2:
								pd[cnt] = new Product(2);
								System.out.print("상품 설명>>");
								pd[cnt].setMenu(sc.next());
								System.out.print("생산자>>");
								pd[cnt].setCon(sc.next());
								System.out.print("가격>>");
								pd[cnt].setPrice(sc.nextInt());
								System.out.print("앨범 제목>>");
								pd[cnt].setAlbumTitle(sc.next());
								System.out.print("가수>>");
								pd[cnt].setSinger(sc.next());
								System.out.println();
								break;
							case 3:
								pd[cnt] = new Product(3);
								System.out.print("상품 설명>>");
								pd[cnt].setMenu(sc.next());
								System.out.print("생산자>>");
								pd[cnt].setCon(sc.next());
								System.out.print("가격>>");
								pd[cnt].setPrice(sc.nextInt());
								System.out.print("책제목>>");
								pd[cnt].setBookTitle(sc.next());
								System.out.print("저자>>");
								pd[cnt].setAuthor(sc.next());
								System.out.print("언어>>");
								pd[cnt].setLang(sc.next());
								System.out.print("ISBN>>");
								pd[cnt].setIsbnNo(sc.nextInt());
								System.out.println();
								break;
							default:
								System.out.println("3개 중에 골라주세요.");
								break;
						}
						cnt++;
						stid = cnt+1;
						break;
					case 2:
						for(int i = 0; i<=cnt-1;i++){
							System.out.println(pd[i].toString());
							System.out.println();
						}
						break;
					case 3:
						System.out.println("종료되었습니다.");
						break;
					default :
						System.out.println("\n3개 중에 골라주세요.");
				}
			}catch(InputMismatchException e){
				System.out.println("숫자를 입력해주세요");
			}
			
		}while(sw[0]!=3);
		sc.close();
	}

}









